﻿<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="tabShipTo.ascx.cs" Inherits="CustomerService.tabShipTo" %>

<script type="text/javascript" language="javascript">
    function USShipToAddress(bUSAddress) {
        var controlEnabled = <%=(_enabled)?"true":"false" %>;
        if (bUSAddress) {
            document.getElementById("tableUSAddress").style.display = "";
            document.getElementById("tableInternationalAddress").style.display = "none";
        }
        else {
            document.getElementById("tableUSAddress").style.display = "none";
            document.getElementById("tableInternationalAddress").style.display = "";
        }
        if (document.getElementById('<%=RequiredCity.ClientID %>') != null)
            document.getElementById('<%=RequiredCity.ClientID %>').enabled = bUSAddress && controlEnabled;
        if (document.getElementById('<%=RequiredZip.ClientID %>') != null)
            document.getElementById('<%=RequiredZip.ClientID %>').enabled = bUSAddress && controlEnabled;
    }

    function InitShipToValidators() {
        tabShipTo_CountryChange();
    }

    function tabShipTo_CountryChange() {
        var ctl = document.getElementById('<%=ddCountry.ClientID %>');
        var id = 280;
        if (ctl.options.count > 0)
            id = ctl.options[ctl.selectedIndex].value;
        USShipToAddress(id == 1 || id == 40);
    }
    
    //Sys.Application.add_load(function() { tabShipTo_CountryChange(); });
    Sys.UI.DomEvent.addHandler(window, "load", tabShipTo_CountryChange);
</script>
<table>
    <tr>
        <td>
            <asp:CheckBox ID="chkSameAsBilling" runat="server" Text="Ship To Billing Address" AutoPostBack="true" OnCheckedChanged="chkSameAsBilling_CheckedChanged" />
            <div id="divShipTo" class="orderform" runat="server">
                <table cellspacing="0" cellpadding="0" border="0" class="CustomerEntry" onload="address_onload();">
                    <tr>
                        <td colspan="2">
                            Country<br />
                            <asp:DropDownList ID="ddCountry" TabIndex="1" runat="server" CausesValidation="True" onchange="tabShipTo_CountryChange();">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:TextBox ID="txtName" runat="server" Enabled="false" />
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="RequiredFirstName" runat="server" Display="None"
                                ControlToValidate="txtFirstName" ErrorMessage="ShipTo First Name Required" EnableClientScript="true" />
                            <cs:LabeledText ID="txtFirstName" TabIndex="1" runat="server" CausesValidation="True"
                                MaxLength="50" Label="First Name" />
                        </td>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="Requiredfieldvalidator2" ControlToValidate="txtLastName" Display="None"
                                runat="server" ErrorMessage="ShipTo Last Name Required" EnableClientScript="true" />
                            <cs:LabeledText ID="txtLastName" Label="Last Name" TabIndex="2" runat="server" CausesValidation="True"
                                MaxLength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <cs:LabeledText ID="txtCompanyName" Label="Company Name" TabIndex="3" runat="server" MaxLength="50"
                            />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:RequiredFieldValidator ID="Requiredfieldvalidator3" ControlToValidate="txtAddress1"
                                runat="server" ErrorMessage="ShipTo Address1 Required" EnableClientScript="true" Display="None" /> 
                            <cs:LabeledText ID="txtAddress1" Label="Address" TabIndex="3" runat="server" CausesValidation="True"
                                MaxLength="100" />
                        </td>
                    </tr>
                </table>
                <table id="tableUSShippingAddress" cellspacing="1" cellpadding="1" border="0" class="CustomerEntry">
                    <tr>
                        <td colspan="2">
                            <cs:LabeledText ID="txtAddress2" Label="Apt. / Unit #" TabIndex="4" runat="server"
                                MaxLength="30" />
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="RequiredCity" ControlToValidate="txtCity"
                                runat="server" ErrorMessage="ShipTo City Required" EnableClientScript="true" Display="None" />
                            <cs:LabeledText ID="txtCity" Label="City" TabIndex="5" runat="server" CausesValidation="True" />
                        </td>
                        <td class="half">
                            State<br />
                            <asp:DropDownList ID="ddState" TabIndex="6" runat="server" CausesValidation="True">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="half">
                            <asp:RequiredFieldValidator ID="RequiredZip" ControlToValidate="txtZip"
                                runat="server" ErrorMessage="ShipTo Zip Required" EnableClientScript="true" Display="None" />
                            <cs:LabeledText ID="txtZip" Label="Zip" TabIndex="7" runat="server" CausesValidation="True"
                                MaxLength="10" />
                        </td>
                    </tr>
                </table>
                <table id="tableInternationalShippingAddress" cellspacing="1" cellpadding="1" border="0"
                    class="CustomerEntry" style="display: none;">
                    <tr>
                        <td colspan="2">
                            <cs:LabeledText ID="txtInternationalAddress2" Label="Address Line #2" TabIndex="8"
                                runat="server" MaxLength="30" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <cs:LabeledText ID="txtInternationalAddress3" Label="Address Line #3" TabIndex="9"
                                runat="server" MaxLength="30" />
                        </td>
                    </tr>
                </table>
            </div>
        </td>
    </tr>
</table>
